<?php

$id=$_GET['matchID'];
function getData($data)
{
	$pieces = explode("-", $data);
	echo $pieces[2]."-".$pieces[1]."-".$pieces[0];
}

function getSquadrabyID( $dbname,$conn,$id)
{

$sql="SELECT `NOME` from `squadre` where `IDS`='$id'";
$res=mysql_db_query($dbname,$sql,$conn) or die(mysql_error());
$info = mysql_fetch_row($res);
echo $info[0];
}

include("connetti.php");


$sql="SELECT `IDP`,`DATA`,`TIPO`,`SQUADRA`,`CASTRASF`,`GOLCASA`,`GOLTRASF`,`MYGOL`,`NUMGIALLI`,`SUBTYPE`,`SUBMINUTE`,`VIDEO`,`VNP`,`NUMROSSI`  FROM presenze WHERE `GIOCATORE`='3' AND `IDP`='$id'";	
	$res=mysql_db_query($dbname,$sql,$conn) or die(mysql_error());
	$num_rows2=mysql_num_rows($res); 
	$num_cols2=mysql_num_fields($res); 

	echo"</br></br><div id='matchContainer' class='container'>";
	for ($z=0; $z<$num_rows2; $z++)
	{
		
		$info = mysql_fetch_row($res);
		echo "<table id='tabledetail' align='center'><tbody><tr class='data'>";
		echo "<td >";
		echo getData($info[1]); 
		echo "</td>";
		echo "<td class='tipo'><img src='images/$info[2].gif'></td><td></td></tr><tr class='partita'>";
		echo "<td >";
		if ($info[4]=="C")
			echo "<div class='centrato'>MILAN</div>";
		else	
		{
			echo "<div class='centrato'>";
			echo getSquadrabyID($dbname,$conn,$info[3]);
			echo "</div>"; 
			}
		echo "</td><td>-</td><td>";
		if ($info[4]=="T")
			echo "<div class='centrato'>MILAN</div>";
		else
		{
			echo "<div class='centrato'>";
			echo getSquadrabyID($dbname,$conn,$info[3]);
			echo "</div>";
						}
			echo "</td></tr><tr class='risultato'><td>";
		echo "<h1> $info[5]</h1></td><td></td><td><h1>$info[6]</h1></td>";
		//if ($info[12]!="")
			//echo "<img src='images/$info[12].jpg'>";
		echo"</tr>";
		
		
		echo "<tr class='note'><td colspan='3'> <div class='info'  ";
		if ($info[4]=="C")
			echo "style='float:left'";
		else
			echo "style='float:right'";
			
		
		
		
		echo ">";
		for ($j=0;$j<$info[7];$j++)
			echo "<img src='images/gol.bmp'/>";
		if ($info[7]>0)
			echo "</br>";
		//echo "($info[7])";

		
		for ($k=0; $k<$info[8]; $k++)
			echo "<img src='images/1G.jpeg'>";
		for ($k=0; $k<$info[13]; $k++)
			echo "<img src='images/1R.jpeg'>";
		//echo "</td></tr>";
		//echo "<tr><td class='note' colspan='3'>"; 
		if ($info[9]!="NUL")
		{
			if ($info[9]=="IN")
				echo "subentrato al ".$info[10]." minuto ";
			if ($info[9]=="OUT")
				echo "sostituito al ".$info[10]." minuto ";
		}
		echo"</div></td></tr>";
		echo "<tr class='video'><td  colspan='3' style='text-align:center;'>";
		echo $info[11];
		echo "</td>";
	
		echo "</tr></tbody></table></div>";
		}


?>
<div>
	<div>
		<div>
		</div>
	</div>
</div>
<div id="fbcomm" style="width:800px; margin-top:50px; margin-bottom:-100px;">

<script src="http://connect.facebook.net/it_IT/all.js#xfbml=1"></script><fb:comments href="<?php
$url ="http://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}";
$url.="?";
$url.="{$_SERVER['QUERY_STRING']}";
echo $url;
?>" num_posts="5" width="750"></fb:comments></div>
